package com.heima.user.controller.v1;

import com.heima.apis.admin.ApUserRealnameControllerApi;
import com.heima.common.constants.user.UserConstants.AdminConstans;
import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.user.dtos.AuthDto;
import com.heima.user.service.ApUserRealnameService;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * Created with IntelliJ IDEA.
 *
 * @Auther: 王可
 * @Date: 2021/01/25/20:41
 * @Description:
 */
@RestController
@RequestMapping("/api/v1/auth")
public class ApUserRealnameController implements ApUserRealnameControllerApi {
    @Resource
    private ApUserRealnameService apUserRealnameService;
    /**
     * 根据状态分页查询
     * @param dto
     * @return
     */
    @PostMapping("/list")
    @Override
    public ResponseResult loadListByStatus(@RequestBody AuthDto dto) {
        return apUserRealnameService.loadListByStatus(dto);
    }

    @PostMapping("/authPass")
    @Override
    public ResponseResult authPass(@RequestBody AuthDto dto) {
        dto.setStatus(AdminConstans.PASS_AUTH);
        return apUserRealnameService.updateByStatus(dto);
    }

    @PostMapping("/authFail")
    @Override
    public ResponseResult authFail(@RequestBody AuthDto dto) {
        dto.setStatus(AdminConstans.FAIL_AUTH);
        return apUserRealnameService.updateByStatus(dto);
    }
}
